<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <!-- 
    使用router-link好在，如果当前路由路径和当前router-link上的路径一致时，会给这个router-link添加激活class
    默认
      router-link-exact-active 
      router-link-active

      router-link-exact-active更精确些
   -->
  <div id="app">
    <router-view></router-view>
    <!-- <a href="#/index">首页</a>
    <a href="#/discover">发现</a>
    <a href="#/order">订单</a>
    <a href="#/profile">我的</a> -->
    <hr>
    <router-link to="/">首页</router-link>
    <router-link to="/discover">发现</router-link>
    <router-link to="/order">订单</router-link>
    <router-link to="/profile">我的</router-link>


  </div>
  <script src="./vue.js"></script>
  <script src="./vue-router.js"></script>
  <script>
    const index = {
      template: `
        <div>首页</div>
      `
    }

    const discover = {
      template: `
        <div>发现</div>
      `
    }

    const order = {
      template: `
        <div>订单</div>
      `
    }

    const profile = {
      template: `
        <div>我的</div>
      `
    }

    const routes = [
      {
        path: '/',
        component: index
      }, {
        path: '/discover',
        component: discover
      }, {
        path: '/order',
        component: order
      }, {
        path: '/profile',
        component: profile
      }
    ]

    const router = new VueRouter({
      routes,
      linkExactActiveClass: 'active'
    })

    const app = new Vue({
      el: '#app',
      router
    })
  
  </script>
</body>
</html>